package com.mycode.view;

import com.mycode.controller.BankEmpOperController;

import javax.swing.*;

/**
 * @author shkstart
 * @create 2021-01-22 10:12
 */
public class BankEmpOper extends JFrame {

    private JButton[] jButton;
    private JTextArea jta;


    public BankEmpOper() {
        //设置标题
        super("银行后台操作");
        //设置大小
        this.setSize(500, 350);
        //设置居中
        this.setLocationRelativeTo(null);
        this.setLayout(null);
        //设置不可变
        this.setResizable(false);
        //添加组件
        addComponents();
        //设置可关闭
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //设置可显示
        this.setVisible(true);
    }

    private void addComponents() {
        String[] strings = {"开户", "冻结用户", "解冻用户", "注销用户", "查看所有用户", "退出"};
        jButton = new JButton[strings.length];
        for (int i = 0; i < jButton.length; i++) {

            jButton[i] = new JButton(strings[i]);

            jButton[i].setBounds(20, (30 + 10) * i + 40, 120, 30);

            this.add(jButton[i]);

        }
        //添加文本域
        jta = new JTextArea();

        JScrollPane jsp = new JScrollPane(jta);

        jsp.setBounds(120 + 20 + 10, 20, 325, 285);
        this.add(jsp);

        BankEmpOperController action = new BankEmpOperController(this);
        for (JButton btn : jButton) {
            btn.addActionListener(action);
        }

    }

    public JButton[] getjButton() {
        return jButton;
    }

    public void setOperBtn(JButton[] jButton) {
        this.jButton = jButton;
    }

    public JTextArea getJta() {
        return jta;
    }

    public void setJta(JTextArea jta) {
        this.jta = jta;
    }

}
